﻿<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true"  Theme="SkinFile"
    CodeFile="TestItem.aspx.cs" Inherits="TestItem" Title="检验能力维护" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder" runat="Server">

    <script type="text/javascript">
    function InvokePopUploadTestItemFile(pccid,ft_id,f_type,rtn_ctgid,rtn_itemid,pageindex)
    {     
        var url= 'uploadfile2.aspx?testitem&pccid='+pccid+'&id='+ft_id+'&type='+f_type+'&rtn_ctgid='+rtn_ctgid+'&rtn_itemid='+'&pageindex='+pageindex ;
        window.open(url,'上传','height=400,width=600,resizable=yes');
    }
    
    </script>
    
    
    <h1 id="pagetitle" class="pagetitle">
        测试项管理
        <asp:UpdateProgress ID="UpdateProgress1" runat="server">
            <ProgressTemplate>
                <div class="anistyle" id="ani">
                    正在加载数据，请耐心等待...
                </div>
            </ProgressTemplate>
        </asp:UpdateProgress>
    </h1>
    <asp:UpdatePanel ID="UpdatePanel" runat="server">
        <ContentTemplate>
            <div runat="server" id="divResult" class="divResult">
                <asp:Label ID="OperationResult" CssClass="result" runat="server" Text=""></asp:Label>
            </div>
            <div class="InfoArea">
                <table width="100%" cellpadding="1" cellspacing="1" bgcolor="#e1e1e1">
                    <tr>
                        <td width="20%" bgcolor="white" valign="top">
                            <div style="overflow-x: auto; overflow-y: auto; height: 380px; width: 200px;">
                                <asp:TreeView ID="testCatalogTreeView" runat="server" Height="100%" ImageSet="WindowsHelp"
                                    OnSelectedNodeChanged="catalogTreeView_SelectedNodeChanged" Width="100%">
                                    <ParentNodeStyle Font-Bold="False" />
                                    <HoverNodeStyle Font-Underline="True" ForeColor="#6666AA" />
                                    <SelectedNodeStyle BackColor="#B5B5B5" Font-Underline="False" HorizontalPadding="0px"
                                        VerticalPadding="0px" />
                                    <NodeStyle Font-Names="Tahoma" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px"
                                        NodeSpacing="0px" VerticalPadding="1px" />
                                </asp:TreeView>
                            </div>
                            <div style="background-color: #E1E1E1; height: 1px; margin-bottom: 2px;">
                            </div>
                            <asp:Button ID="BtnAddCatalog" runat="server" Text="添  加" ToolTip="添加测试分类目录" OnClick="btnAddCatalog_Click" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <asp:Button ID="BtnDelCatalog" runat="server" Text="删   除" ToolTip="删除选中的测试分类目录"
                                OnClick="btnRemoveCatalog_Click" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <asp:Button ID="BtnEditCatalog" runat="server" Text="编   辑" ToolTip="编辑选中的测试分类目录"
                                OnClick="BtnEditCatalog_Click" />
                        </td>
                        <td width="80%" bgcolor="white" valign="top">
                            <div>
                                <span style="float: left; margin-top: 4px;"><b>当前目录：</b><asp:Label ID="labNowCatalog"
                                    runat="server" Text="" Font-Bold="True"></asp:Label>
                                </span><span style="float: right;">
                                    <asp:Button ID="btnCreateItem" runat="server" Text="在当前目录下添加检验项" OnClick="btnCreateItem_Click" />
                                </span>
                            </div>
                            <br style="clear: both;" />
                            <div style="height: 240px; overflow: hidden; display: block; border-top: solid 1px #e1e1e1;">
                                <asp:GridView ID="GridViewTestItem" runat="server" CellPadding="4" ForeColor="#333333"
                                    GridLines="None" DataKeyNames="Test_Ctg_ID" Width="100%" AutoGenerateColumns="False" SkinID="gridviewSkin">
                                    <Columns>
                                        <asp:BoundField DataField="Test_Ctg_ID" HeaderText="编号">
                                            <HeaderStyle HorizontalAlign="Left" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="Test_Ctg_Name" HeaderText="测试名称">
                                            <HeaderStyle HorizontalAlign="Left" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="Dept_Name" HeaderText="负责部门" />
                                        <asp:BoundField DataField="price" HeaderText="价格">
                                            <HeaderStyle HorizontalAlign="Left" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="Create_Time" HeaderText="创建时间">
                                            <HeaderStyle HorizontalAlign="Left" />
                                        </asp:BoundField>
                                        <asp:TemplateField HeaderText="操作">
                                            <ItemTemplate>
                                                <asp:LinkButton ID="lbDetailItem" runat="server" OnClick="lbDetailItem_Click">详细</asp:LinkButton>
                                                <asp:LinkButton ID="lbEditItem" runat="server" OnClick="lbEditItem_Click">编辑</asp:LinkButton>
                                                <asp:LinkButton ID="lbDelItem" runat="server" OnClick="lbDelItem_Click" OnClientClick="javascript:return confirm('您确定要删除该检验项吗？');">删除</asp:LinkButton>
                                            </ItemTemplate>
                                            <ItemStyle Width="120px" HorizontalAlign="Right" />
                                            <HeaderStyle HorizontalAlign="Center" />
                                        </asp:TemplateField>
                                    </Columns>
                                </asp:GridView>
                                <webdiyer:AspNetPager ID="AspNetPager1" runat="server" ShowCustomInfoSection="Left"
                                    CustomInfoHTML="记录数：%RecordCount%，总页数：%PageCount%，第%CurrentPageIndex%页" CustomInfoTextAlign="left"
                                    CustomInfoStyle="padding-top:8px;font-weight:bold;" HorizontalAlign="right" FirstPageText="首页"
                                    LastPageText="尾页" NextPageText="下一页" OnPageChanged="AspNetPager1_PageChanged"
                                    PrevPageText="上一页" ShowPageIndexBox="Always" SubmitButtonText="Go" TextAfterPageIndexBox="页"
                                    TextBeforePageIndexBox="转到" CssClass="anpager" CurrentPageButtonClass="cpb">
                                </webdiyer:AspNetPager>
                            </div>
                            <br style="clear: both;" />
                            <div style="border-bottom: solid 1px #e1e1e1;">
                                <span style="float: left; margin-top: 4px;"><b>当前检验项：</b><asp:Label ID="labNowItem"
                                    runat="server" Text="" Font-Bold="True"></asp:Label>
                                </span><span style="float: right;">
                                    <asp:Button ID="btnCreateTemplate" runat="server" Text="创建参数模板" OnClick="btnCreateTemplate_Click"
                                        Visible="False" />
                                </span>
                                    
                            </div>
                            <br style="clear: both;" />
                            <div style="padding-top: 4px;">
                                <span style="float: left;">备注信息： </span><span>
                                    <asp:Label ID="labMemo" runat="server" Text=""></asp:Label>
                                </span>
                            </div>
                            <br style="clear: both;" />
                            <div><asp:Button ID="BtnUploadParFileHidden" runat="server" OnClick="btnUploadParFile_Click"
                                Style="display: none" Text="" />
                                <asp:Repeater ID="RepTemplate" runat="server" OnItemCommand="RepTemplate_ItemCommand">
                                    <HeaderTemplate>
                                        <table width="100%" cellpadding="0" cellspacing="0">
                                            <tr style="background-color: #f1f1f1; font-weight: bold; color: Gray;">
                                                <td style="width: 80px;">
                                                    模板编号</td>
                                                <td style="width: 150px;">
                                                    Doc模板</td>
                                                <td style="width: 150px;">
                                                    Xls模板</td>
                                                <td>
                                                    创建时间</td>
                                                <td style="width: 50px;">
                                                    删除</td>
                                            </tr>
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <tr>
                                            <td>
                                                <%# DataBinder.Eval(Container.DataItem, "FT_ID")%>
                                            </td>
                                            <td>
                                             
                                             <%# DataBinder.Eval(Container.DataItem, "DOCNAME").ToString() == "" ? "<a href='javascript:void(0);'  onclick=InvokePopUploadTestItemFile('" +this.BtnUploadParFileHidden.ClientID+"','"+ DataBinder.Eval(Container.DataItem, "FT_ID").ToString() + "','doc','" + testCatalogTreeView.SelectedValue + "','" + ViewState["ITEMID"].ToString() + "'," + AspNetPager1.CurrentPageIndex.ToString() + ")   title='上传Doc模板'>添加Doc模板</a>" : "<a href='getfile.aspx?fileid=" + DataBinder.Eval(Container.DataItem, "Doc_Url") + "' title='下载Doc模板'>" + DataBinder.Eval(Container.DataItem, "DOCNAME") + "</a>"%>
                                            </td>
                                            <td>
                                                <%# DataBinder.Eval(Container.DataItem, "XLSNAME").ToString() == "" ? "<a href='javascript:void(0);' onclick=InvokePopUploadTestItemFile('" + this.BtnUploadParFileHidden.ClientID + "','" + DataBinder.Eval(Container.DataItem, "FT_ID").ToString() + "','xls','" + testCatalogTreeView.SelectedValue + "','" + ViewState["ITEMID"].ToString() + "'," + AspNetPager1.CurrentPageIndex.ToString() + ")   title='上传Xls模板'>添加Xls模板</a>" : "<a href='getfile.aspx?fileid=" + DataBinder.Eval(Container.DataItem, "Xls_Url") + "' title='下载Doc模板'>" + DataBinder.Eval(Container.DataItem, "XLSNAME") + "</a>"%>
                                            </td>
                                            <td>
                                                <%# DataBinder.Eval(Container.DataItem, "Create_Time","{0:yyyy-MM-dd}")%>
                                            </td>
                                            <td>
                                                <asp:LinkButton ID="lbDelTemplate" runat="server" CommandName='<%# DataBinder.Eval(Container.DataItem, "FT_ID")%>'
                                                    ToolTip="删除该对模板" OnClientClick="javascript:return confirm('您确定要删除这两个模板吗？系统将同时删除Word和Excel模板文件！');">删除</asp:LinkButton>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="background-color: #e1e1e1; height: 1px;" colspan="5">
                                            </td>
                                        </tr>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        </table>
                                    </FooterTemplate>
                                </asp:Repeater>
                            </div>
                        </td>
                    </tr>
                </table>
            </div>
            <br style="clear: both;" />
            <asp:Panel ID="panelDelCatalog" runat="server" Style="display: none; width: 400px;"
                CssClass="modalPopup">
                <div id="dragDelCatalog" class="windowbar">
                </div>
                <br />
                <strong>注意：</strong>系统仅允许删除空检验项目录！如果检验项目录下有检验项，则不允许删除。如果确实要删除检验项目录及目录下的所有子项（检验项目录和检验项），请先删除下级各级检验项目录中的检验项，然后逐步删除各个检验项目录。
                <br />
                <br />
                <asp:Label ID="lbCatalogToDelInfo" runat="server" Font-Bold="True"></asp:Label>
                <br />
                <br />
                <hr />
                <div style="text-align: right;">
                    <asp:Button ID="btnDelCatalogOK" runat="server" Text="确定" OnClick="btnDelCatalog_OK" />
                    <asp:Button ID="btnCancelCatalog" runat="server" Text="取消" />
                </div>
            </asp:Panel>
            <asp:Panel ID="panelAddCatalog" runat="server" Style="display: none; width: 400px;"
                CssClass="modalPopup">
                <div id="dragAddCatalog" class="windowbar">
                </div>
                <br />
                在检验目录<b><asp:Label ID="lbCurrentCatalog" runat="server"></asp:Label></b>下添加子测试目录，请输入新检验目录名称：
                <br />
                <asp:TextBox ID="txtSubCatalog" runat="server" MaxLength="50" ToolTip="测试项分类名称" Width="395"
                    EnableViewState="False" ValidationGroup="GCatalogAdd"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ControlToValidate="txtSubCatalog"
                    Display="Dynamic" ErrorMessage="分类目录名称不能为空!" ValidationGroup="GCatalogAdd"></asp:RequiredFieldValidator><br />
                备注：<br />
                <asp:TextBox ID="txtSubCatalogMemo" runat="server" EnableViewState="False" MaxLength="50"
                    TextMode="MultiLine" ToolTip="备注." ValidationGroup="GAddCatalog" Width="395"></asp:TextBox><br />
                <br />
                <hr />
                <div style="text-align: right;">
                    <asp:Button ID="btnAddCatalogOK" runat="server" Text="确定" OnClick="btnAddCatalogOK_Click"
                        ValidationGroup="GCatalogAdd" />
                    <asp:Button ID="btnAddCatalogCancel" runat="server" Text="取消" CausesValidation="False" />
                    <br />
                </div>
            </asp:Panel>
            <asp:Panel ID="panelEditCatalog" runat="server" Style="display: none; width: 400px;"
                CssClass="modalPopup">
                <div id="dragEidtCatalog" class="windowbar">
                </div>
                <br />
                分类目录编号：<br />
                <asp:Label ID="labEditCatalogID" runat="server" CssClass="id" Font-Bold="True"></asp:Label><br />
                分类目录名称：<br />
                <asp:TextBox ID="txtEditCatalogName" runat="server" EnableViewState="False" MaxLength="50"
                    ToolTip="测试目录名不可超过50个字符" Width="395" ValidationGroup="GCatalogEdit"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtEditCatalogName"
                    Display="Dynamic" ErrorMessage="分类目录名称不能为空!" ValidationGroup="GCatalogEdit"></asp:RequiredFieldValidator><br />
                备注：
                <br />
                <asp:TextBox ID="txtEditCatalogMemo" runat="server" EnableViewState="False" MaxLength="50"
                    TextMode="MultiLine" ToolTip="测试目录名不可超过50个字符" Width="395" ValidationGroup="GAddCatalog"></asp:TextBox><br />
                <br />
                <hr />
                <div style="text-align: right;">
                    <asp:Button ID="btnEditCatalogSave" runat="server" Text="确定" OnClick="btnEditCatalogSave_Click"
                        ValidationGroup="GCatalogEdit" />
                    <asp:Button ID="btnEditCatalogCancel" runat="server" Text="取消" CausesValidation="False"
                        ValidationGroup="GEditCatalog" />
                </div>
            </asp:Panel>
            <asp:Button runat="server" ID="hiddenTargetControlForModalPopup1" Style="display: none" />
            <asp:Button runat="server" ID="hiddenTargetControlForModalPopup2" Style="display: none" />
            <asp:Button runat="server" ID="hiddenTargetControlForModalPopup3" Style="display: none" />
            <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderDelCatalog" TargetControlID="hiddenTargetControlForModalPopup2"
                runat="server" CancelControlID="btnCancelCatalog" BehaviorID="programmaticModalPopupBehavior2"
                PopupDragHandleControlID="dragDelCatalog" PopupControlID="panelDelCatalog" BackgroundCssClass="modalBackground">
            </ajaxToolkit:ModalPopupExtender>
            <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderAddCatalog" TargetControlID="hiddenTargetControlForModalPopup1"
                BehaviorID="programmaticModalPopupBehavior" runat="server" CancelControlID="btnAddCatalogCancel"
                PopupDragHandleControlID="dragAddCatalog" PopupControlID="panelAddCatalog" BackgroundCssClass="modalBackground">
            </ajaxToolkit:ModalPopupExtender>
            <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderEditCatalog" TargetControlID="hiddenTargetControlForModalPopup3"
                runat="server" CancelControlID="btnEditCatalogCancel" PopupDragHandleControlID="dragEidtCatalog"
                PopupControlID="panelEditCatalog" BackgroundCssClass="modalBackground">
            </ajaxToolkit:ModalPopupExtender>
            <asp:Button runat="server" ID="Button1" Style="display: none" />
            <asp:Panel ID="panelItemAdd" runat="server" Style="display: none; width: 400px;"
                CssClass="modalPopup">
                <div id="dragItemAdd" class="windowbar">
                </div>
                <br />
                检测目录名称：<asp:Label ID="labItemAddCatalog" runat="server" Font-Bold="True"></asp:Label><br />
                测试项名称：<br />
                <asp:TextBox ID="txtItemAddName" runat="server" EnableViewState="False" MaxLength="50"
                    ToolTip="测试目录名不可超过50个字符" Width="395" ValidationGroup="GItemAdd"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="txtItemAddName"
                    Display="Dynamic" ErrorMessage="测试项名称不能为空!" ValidationGroup="GItemAdd"></asp:RequiredFieldValidator><br />
                执行部门：<br />
                <asp:DropDownList ID="ddlItemAddDept" runat="server" Width="400px" ValidationGroup="GItemAdd">
                </asp:DropDownList><br />
                检验参数：<br />
                <asp:TextBox ID="txtItemAddParameter" runat="server" EnableViewState="False" MaxLength="50"
                    TextMode="MultiLine" Width="395" ValidationGroup="GItemAdd"></asp:TextBox><br />
                价格：<br />
                <asp:TextBox ID="txtItemAddPrice" runat="server" EnableViewState="False" MaxLength="50"
                    Width="395" ValidationGroup="GItemAdd"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtItemAddPrice"
                    Display="Dynamic" ErrorMessage="检验价格不能为空!" ValidationGroup="GItemAdd"></asp:RequiredFieldValidator><br />
                能力状态：<br />
                <asp:DropDownList ID="ddlItemAddStatus" runat="server" Width="400px">
                    <asp:ListItem Value="2">可执行</asp:ListItem>
                    <asp:ListItem Value="1">不可执行</asp:ListItem>
                    <asp:ListItem Value="0">未知</asp:ListItem>
                </asp:DropDownList><br />
                备注：
                <br />
                <asp:TextBox ID="txtItemAddMemo" runat="server" EnableViewState="False" MaxLength="50"
                    TextMode="MultiLine" ToolTip="测试目录名不可超过50个字符" Width="395"></asp:TextBox><br />
                <br />
                <hr />
                <div style="text-align: right;">
                    <asp:Button ID="btnItemCreateSave" runat="server" Text="保存" OnClick="btnItemCreateSave_Click"
                        ValidationGroup="GItemAdd" />
                    <asp:Button ID="btnItemCreateCancel" runat="server" Text="取消" CausesValidation="False" />
                    <br />
                </div>
            </asp:Panel>
            <ajaxToolkit:ModalPopupExtender ID="mpeItemAdd" TargetControlID="Button1" runat="server"
                PopupDragHandleControlID="dragItemAdd" CancelControlID="btnItemCreateCancel"
                PopupControlID="panelItemAdd" BackgroundCssClass="modalBackground">
            </ajaxToolkit:ModalPopupExtender>
            <asp:Button runat="server" ID="Button2" Style="display: none" />
            <asp:Panel ID="panelItemEdit" runat="server" Style="display: none; width: 400px;"
                CssClass="modalPopup">
                <div id="dragItemEdit" class="windowbar">
                </div>
                <br />
                分类目录编号：<br />
                <asp:Label ID="labItemEditID" runat="server" CssClass="id" Font-Bold="True"></asp:Label><br />
                分类目录名称：<br />
                <asp:TextBox ID="txtItemEidtName" runat="server" EnableViewState="False" MaxLength="50"
                    ToolTip="测试目录名不可超过50个字符" Width="395" ValidationGroup="GItemEdit"></asp:TextBox><br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtItemEidtName"
                    ErrorMessage="检验项名称不能为空!" ValidationGroup="GItemEdit" Display="Dynamic"></asp:RequiredFieldValidator><br />
                执行部门：<br />
                <asp:DropDownList ID="ddlItemEidtDept" runat="server" Width="400px">
                </asp:DropDownList><br />
                检验参数：<br />
                <asp:TextBox ID="txtItemEidtParameter" runat="server" EnableViewState="False" MaxLength="50"
                    TextMode="MultiLine" Width="395" ValidationGroup="GItemEdit"></asp:TextBox><br />
                价格：<br />
                <asp:TextBox ID="txtItemEidtPrice" runat="server" EnableViewState="False" MaxLength="50"
                    Width="395" ValidationGroup="GItemEdit"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtItemEidtPrice"
                    Display="Dynamic" ErrorMessage="检验价格不能为空!" ValidationGroup="GItemEdit"></asp:RequiredFieldValidator><br />
                能力状态：<br />
                <asp:DropDownList ID="ddlItemEidtStatus" runat="server" Width="400px">
                    <asp:ListItem Value="2">可执行</asp:ListItem>
                    <asp:ListItem Value="1">不可执行</asp:ListItem>
                    <asp:ListItem Value="0">未知</asp:ListItem>
                </asp:DropDownList><br />
                备注：
                <br />
                <asp:TextBox ID="txtItemEidtMemo" runat="server" EnableViewState="False" MaxLength="50"
                    TextMode="MultiLine" ToolTip="测试目录名不可超过50个字符" Width="395"></asp:TextBox><br />
                <br />
                <hr />
                <div style="text-align: right;">
                    <asp:Button ID="btnItemEidtSave" runat="server" Text="保存" OnClick="btnItemEidtSave_Click"
                        ValidationGroup="GItemEdit" />
                    <asp:Button ID="btnItemEditCancel" runat="server" Text="取消" CausesValidation="False" />
                    <br />
                </div>
            </asp:Panel>
            <ajaxToolkit:ModalPopupExtender ID="mpeItemEdit" TargetControlID="Button2" runat="server"
                PopupDragHandleControlID="dragItemEdit" CancelControlID="btnItemEditCancel" PopupControlID="panelItemEdit"
                BackgroundCssClass="modalBackground">
            </ajaxToolkit:ModalPopupExtender>
            <br style="clear: both;" />
        </ContentTemplate>
    </asp:UpdatePanel>
</asp:Content>
